#pragma once
#ifndef _ENGINEPLUG
#define _ENGINEPLUG

struct DebugLine
	{
	NxVec3	p0;
	NxVec3	p1;
	unsigned int	color;
	};
class CustomDebugRenderable
{
public:
	CustomDebugRenderable() {
		numLines = 0; lines = 0;
	}
	~CustomDebugRenderable(){
		if(lines) delete lines;
	}
	inline int	getNbLines() const				{ return numLines; }
	inline const DebugLine* getLines() const			{ return lines; }

	int numLines;
	DebugLine* lines;
};


extern "C" {
#ifdef DSPLUGINII_EXPORTS
	#define DSPLUGIN_API __declspec(dllexport)
#else
	#define DSPLUGIN_API __declspec(dllimport)
#endif

DSPLUGIN_API char*		getPhysicsEngineName();
DSPLUGIN_API bool		initEngine(float UPM, float gravity);
DSPLUGIN_API const		CustomDebugRenderable* updateSimulation(float time);
DSPLUGIN_API void		clearSimulation();
DSPLUGIN_API int		createNewActor(const PhysicsActor* act, const NxVec3 position, int newSkeletonID);		//returns index
DSPLUGIN_API int		createJoint(const PhysicsJoint* joint);
DSPLUGIN_API void		toggleDebugVisualisation(bool b);
DSPLUGIN_API void		createGround(bool onoff);
DSPLUGIN_API NxVec3	getActorPosition(int id);
DSPLUGIN_API NxMat33	getActorOrientation(int id);
DSPLUGIN_API bool		saveScene(const char* name, const PhysicsEntity* scene);
DSPLUGIN_API bool		loadScene(const char* name, PhysicsEntity* scene);
DSPLUGIN_API int		loadMeshCollision(const float* verts, const int* polys, bool convex);
DSPLUGIN_API void		setValue(int type, float value);
DSPLUGIN_API float		getValue(int type);
DSPLUGIN_API void		setSkinWidth(float skin);
DSPLUGIN_API char*		askIfCookMesh(const char* pathRoot, const char* filename, const PhysicsMesh* meshData);
DSPLUGIN_API void		updateGravity(float grav);
DSPLUGIN_API int		createSkeletalModel(const PhysicsModel* model);
DSPLUGIN_API NxVec3	getBonePosition(int charID, char*  boneName);
DSPLUGIN_API NxMat33	getBoneOrientation(int charID, char* boneName);
DSPLUGIN_API void		setBonePosition(int charID, char* boneName, NxVec3 pos, NxMat33 rot);

//these functions are for Newton plugin only
DSPLUGIN_API physHittest_t*	mouseScan(NxVec3 origin, NxVec3 dir, int group);
DSPLUGIN_API void			releaseStaticBox(int id);
DSPLUGIN_API int			createStaticBox(const NxVec3 dimensions, const NxVec3 position, int gizmoID, int group, bool simScene);
DSPLUGIN_API void			setStaticPosition(int id, NxVec3 pos);
DSPLUGIN_API void			setStaticOrientation(int id, NxMat33 pos);
DSPLUGIN_API NxMat33		getStaticOrientation(int id);

}
#endif
